package de.matusystems

class NewsletterController {

	def newsletterService

	def generateNewsletter = {
		Newsletter newsletter = newsletterService.generateNewsletter()
		render newsletter.htmlContent
	}

	def send = {
		def result = newsletterService.sendNewsletter()
		if(!result){
			flash.message = "There is no newsletter to send."
		}else{
			flash.message = "Newsletter from ${result['newsletter'].dateCreated} sent to ${result['users'].size} users."
		}
	}
}
